import { ocr } from '@/request/api'

import type { Directive, DirectiveBinding } from "vue"
let unploadImg:Directive ={
    mounted:((el:HTMLInputElement,binding:DirectiveBinding)=>{
        el.addEventListener('change',(e:Event)=>{
            const file =((e?.target as HTMLInputElement).files as FileList)[0]
            const reader = new FileReader()
            reader.addEventListener('load', () => {
                const formData = new FormData()
                formData.append('image',reader.result as string)
                ocr(formData).then(res=>{
                    console.log(res)
                })
            })
            reader.readAsDataURL(file)
        })
    })
}
export default unploadImg